//服务器：接收数据，给出反馈

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class TCP_Demo1_server {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(10000);
        Socket accept = serverSocket.accept();
        InputStream acceptInputStream = accept.getInputStream();
        byte[] bys = new byte[1024];
        int len = acceptInputStream.read(bys);
        System.out.println("The message from client is : \n " + new String(bys,0,len));

        OutputStream acceptOutputStream = accept.getOutputStream();
        acceptOutputStream.write("I`m the server.".getBytes());

        serverSocket.close();
    }
}
